import numpy as np
class Counter:
    def __init__(self):
        self.idx=0
        self.__counts=np.zeros((320,4),dtype=np.int)
    def record(self,clss):
        if self.idx==320:
            self.idx=0
        idx=self.idx
        self.__counts[idx][:]=0
        for i in clss:
            self.__counts[idx][i-1]=1
        self.idx+=1
        return idx
    def sum(self,sec,idx):
        cnt=idx-sec*20
        result=np.zeros(4,dtype=np.int)
        for i in range(idx,cnt,-1):
            if i<0:i+=320
            result+=self.__counts[i]
        return result
            
    
